/*
 * @Author: Eureka 
 * @Date: 2019-10-31 17:57:45 
 * @Last Modified by: Eureka
 * @Last Modified time: 2021-11-10 18:39:22
 */
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:senkoo_platform/Utils/is_empty.dart';

class ImageUtils {
  static ImageProvider getAssetImage(String? name, {String format = 'png'}) {
    return AssetImage(getImgPath(name, format: format));
  }

  static String getImgPath(String? name, {String format = 'png'}) {
    return 'assets/image/$name.$format';
  }

  static ImageProvider getImageProvider(String imageUrl,
      {String holderImg = "supplement/picture_default"}) {
    try {
      if (EmptyUtil.isEmpty(imageUrl)) {
        return AssetImage(getImgPath(holderImg));
      }
      return ExtendedNetworkImageProvider(imageUrl, cache: false);
    } catch (e) {
      return AssetImage(getImgPath(holderImg));
    }
  }
}
